x86/NUMA: correct memnode_shift calculation for single node system
authorJan Beulich <jbeulich@suse.com>
Thu, 29 Sep 2022 12:39:52 +0000 (14:39 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 29 Sep 2022 12:39:52 +0000 (14:39 +0200)
commit0db195c1a9947240b354abbefd2afac6c73ad6a8
tree9c5d07b717e0cf4f473a799ba1e0555cf85f48c9
parente1de23b7c1bfa02447a79733e64184b3635e0587
x86/NUMA: correct memnode_shift calculation for single node system

SRAT may describe even a single node system (including such with
multiple nodes, but only one having any memory) using multiple ranges.
Hence simply counting the number of ranges (note that function
parameters are mis-named) is not an indication of the number of nodes in
use. Since we only care about knowing whether we're on a single node
system, accounting for this is easy: Increment the local variable only
when adjacent ranges are for different nodes. That way the count may
still end up larger than the number of nodes in use, but it won't be
larger than 1 when only a single node has any memory.

To compensate populate_memnodemap() now needs to be prepared to find
the correct node ID already in place for a range. (This could of course
also happen when there's more than one node with memory, while at least
one node has multiple adjacent ranges, provided extract_lsb_from_nodes()
would also know to recognize this case.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/numa.c